//
//  LeftViewController.m
//  UI_Custom
//
//  Created by yutao on 15/2/12.
//  Copyright (c) 2015年 yutao. All rights reserved.
//

#import "LeftViewController.h"

@interface LeftViewController ()

@end

@implementation LeftViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 30, self.view.frame.size.width, 228) style:UITableViewStylePlain];
    tableView.backgroundColor = [UIColor grayColor];
    tableView.delegate = self;
    tableView.dataSource = self;
    [self.view addSubview:tableView];

    
}
#pragma mark - UITableViewDataSource

- (NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section {
    return 4;
}

- (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *CellIdentifier = @"CellIdentifier";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if(cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }
    
    /*
     * Content in this cell should be inset the size of kMenuOverlayWidth
     */
    
    if (indexPath.row == 0) {
        cell.textLabel.text = @"推荐";

    }
    if (indexPath.row == 1) {
        cell.textLabel.text = @"食疗大全";
        
    }
    if (indexPath.row == 2) {
        cell.textLabel.text = @"健康知识";
        
    }
    if (indexPath.row == 3) {
        cell.textLabel.text = @"我的";
        
    }
    return cell;
    
}

- (NSString*)tableView:(UITableView*)tableView titleForHeaderInSection:(NSInteger)section {
    return @"💓贴心护士";
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 50;
}


#pragma mark - UITableViewDelegate

- (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    
    DDMenuController *menuController = (DDMenuController*)((AppDelegate*)[[UIApplication sharedApplication] delegate]).menuController;
    
    // 设置根视图
    if (indexPath.row == 0) {
        
        RecommendViewController *controller = [[RecommendViewController alloc] init];
        controller.title = [NSString stringWithFormat:@"推荐"];
        UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:controller];
        
        [menuController setRootController:navController animated:YES];

    }
    if (indexPath.row == 1) {
        
        FoodTherapyHomeViewController *controller = [[FoodTherapyHomeViewController alloc] init];
        controller.title = [NSString stringWithFormat:@"食疗大全"];
        UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:controller];
        
        [menuController setRootController:navController animated:YES];

    }
    if (indexPath.row == 2) {
        
        HealthKnowledgeViewController *controller = [[HealthKnowledgeViewController alloc] init];
        controller.title = [NSString stringWithFormat:@"健康知识"];
        UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:controller];
        
        [menuController setRootController:navController animated:YES];

    }
    if (indexPath.row == 3) {
        
        MineViewController *controller = [[MineViewController alloc] init];
        controller.title = [NSString stringWithFormat:@"我的"];
        UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:controller];
        
        [menuController setRootController:navController animated:YES];
        
    }

    
        [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
